﻿using Pb;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DDZCoinJoinRoom : MonoBehaviour {

    public GameObject CommonBtn;
    public GameObject LocalTyrantBtn;
    public GameObject ExtremeBtn;

    public List<UILabel> baseScore;
    public List<UILabel> limitScore;
    private void Awake()
    {
        UIEventListener.Get(CommonBtn).onClick = ButtonClick;
        UIEventListener.Get(LocalTyrantBtn).onClick = ButtonClick;
        UIEventListener.Get(ExtremeBtn).onClick = ButtonClick;
    }
    private void Start()
    {
        EginUser user = EginUser.Instance;
        for (int i = 0; i < 3; i++)
        {
            string str = user.ReturnRelCoinForBrief(user.ddzRoomList[i].BaseScore);
            Debug.Log(str);
            baseScore[i].text = "底分：" + str + "金币";
            string str1 = user.ReturnRelCoinForBrief(user.ddzRoomList[i].EnterLimit);
            Debug.Log(str1);
            limitScore[i].text = str1 + "金币准入";
        }
    }
    void ButtonClick(GameObject button)
    {
        if (button.name == "CommonBtn")
        {
            SendCoinJoinRoom(1);
        }
        else if (button.name == "LocalTyrantBtn")
        {
            SendCoinJoinRoom(2);
        }
        else if (button.name == "ExtremeBtn")
        {
            SendCoinJoinRoom(3);
        }
    }

    void SendCoinJoinRoom(int typeId)
    {
        DdzRandomEnterRoomRequest lg = new Pb.DdzRandomEnterRoomRequest { TypeId = typeId };
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendProtobuf1(lg, MsgId.DdzRandomEnterRoomRequest);
    }
}
